package exercise2;

public class TestAnimals{
	public static void  gan  (Animal h)	{
		if(h instanceof Cat) {
			Cat b=(Cat) h;
			 b.play();
		}
		else if(h instanceof Fish) {
			Fish b=(Fish) h;
			b.play();
		}
	}
	public static void main (String args[]) {
	Fish d = new Fish();
	Cat c = new Cat("Fluffy");
	Animal a = new Fish();
	Animal e = new Spider();
	Pet p = new Cat();
	gan(a);
	gan(c);
	gan(d);
	gan(e);
	System.out.println("The cat's name is "+c.getName());
	p.play();
	}

}
